/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PPanelTemplate.java
 *
 * Created on 13-mar-2011, 19.44.58
 */

package presentation;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;

/**
 *
 * @author quirino
 */
public class PPanelTemplate extends javax.swing.JLayeredPane {

    private Image img;
    private String pathImg;

    public PPanelTemplate(){
        super();
    }

    /** Creates new form PPanelTemplate */
    public PPanelTemplate(String img) {
        super();
        this.pathImg= img;
        this.img= new ImageIcon(this.pathImg).getImage();
        initComponents();
    }

    public void paintComponent(Graphics g) {

        g.drawImage(this.img, 0, 0, this.getSize().width, this.getSize().height, null);

        /*
        BufferedImage originalImage = null;
        try {
            originalImage = ImageIO.read(new File(this.pathImg));
            int type = originalImage.getType() == 0? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
            BufferedImage resizedImage = new BufferedImage(this.getSize().width,
                    this.getSize().height, type);
            Graphics2D g2d = (Graphics2D) g;
            g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                            RenderingHints.VALUE_INTERPOLATION_BILINEAR);
            g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                            RenderingHints.VALUE_RENDER_QUALITY);
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
            g2d.drawImage(originalImage, 0, 0, this.getSize().width,
                    this.getSize().height, null);
            g2d.dispose();
            super.paintComponent(g2d);
        } catch (IOException e) {
            System.out.println(e.toString());
        }
        */
    }

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
